package com.spzx.channel.confifgure;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        // int processors = Runtime.getRuntime().availableProcessors();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10, 20, 4000, TimeUnit.SECONDS, new ArrayBlockingQueue<>(200));
        threadPoolExecutor.prestartAllCoreThreads();
        return threadPoolExecutor;
    }

}
